﻿using System;
using System.Collections.Generic;

namespace DotNetRepository.UnitTests
{
    public class Customer : IEntity
    {
        public Guid ID { get; set; }

        public long Version { get; set; }

        public void IncrementVersion()
        {
            Version++;
        }

        public Customer()
        {
            _orders = new EntityCollection<Order>(
            new EntityCollectionArgs<Order>
                {
                    Container = this,
                    Association = o=>o.CustomerID == ID,
                    SetForeignKey = (order,customer) => order.CustomerID = customer.ID,
                    DeleteOnRemove = true,
                });
        }

        public string Name { get; set; }

        private readonly IEntityCollection<Order> _orders;
        public ICollection<Order> Orders { get{ return _orders;}}
    }
}
